package com.parkinglot.service.Impl;


import com.parkinglot.dao.WechatconfigDao;
import com.parkinglot.pojo.Wechatconfig;
import com.parkinglot.service.WechatconfigService;
import com.parkinglot.util.ImgUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * (Wechatconfig)表服务实现类
 *
 * @author makejava
 * @since 2020-12-09 17:10:54
 */
@Slf4j
@Service("wechatconfigService")
public class WechatconfigServiceImpl implements WechatconfigService {

    @Resource
    private WechatconfigDao wechatconfigDao;

    @Override
    public Wechatconfig addimg(Wechatconfig wechatconfig, MultipartFile[] files, HttpServletRequest request) {
        int code=0;
        Wechatconfig wechatconfig1=null;
        try {

            ImgUtils imgUtils=  new ImgUtils();
            List<String> imagepaths = imgUtils.getOrderDtl(files,request);
            for (String imgpath:imagepaths) {
                wechatconfig.setTitleimgpath(imgpath);
                wechatconfig.setBackgroundimg(imgpath);
                wechatconfigDao.insert(wechatconfig);
            }
            wechatconfig1=wechatconfigDao.queryAll(wechatconfig);
        }catch (Exception e){
            log.warn("异常对象:{},异常消息:{},异常栈信息:{}", e.getClass(), e.getMessage());
            e.printStackTrace();
        }
        return wechatconfig1;
    }
}